/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tudou.searchcontrol.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tudou.searchcontrol.model.PageInfo;

import com.tudou.searchcontrol.dao.PlaysourceDao;
import com.tudou.searchcontrol.model.Playsource;
import com.tudou.searchcontrol.service.IPlaysourceService;

@Service("playsourceService")
public class PlaysourceService implements IPlaysourceService {

	@Autowired
	private PlaysourceDao playsourceDao;
	
	public PageInfo getPlaysourceByPage(Map searchMap,PageInfo pageInfo){
		return playsourceDao.getObjectPageInfo(searchMap,pageInfo);
	}
	
	public List<Playsource> getPlaysourceList(Map searchMap){
		return playsourceDao.getObjectList(searchMap);
	}
	
	public int saveOrUpdatePlaysource(Playsource playsource){
		if(playsource.getId() == null){
			return playsourceDao.addObject(playsource);
		}else{
			return playsourceDao.updateObject(playsource);
		}
	}
	
	public Playsource getPlaysourceById(Long id){
		return playsourceDao.getObjectById(id);
	}
	
	public int deletePlaysource(String ids){
		int delNum = 0;
		if(StringUtils.isNotEmpty(ids)){
			String[] idstr = ids.split(",");
			for(int i=0;i<idstr.length;i++){
				delNum = playsourceDao.deleteObject(Long.valueOf(idstr[i]));
			}
		}
		return delNum;
	}
	
	public Playsource getPlaysource(Map searchMap){
		return playsourceDao.getObject(searchMap);
	}

}
